class Solution(object):
    def findTheDifference(self, s, t):
        """
        :type s: str
        :type t: str
        :rtype: str
        """
        # 法一：采用字典的方式
        # s_freq = {}
        # t_freq = {}
        # for a in s:
        #     if a not in s_freq:
        #         s_freq[a] = 1
        #     else:
        #         s_freq[a] += 1
        # for b in t:
        #     if b not in t_freq:
        #         t_freq[b] = 1
        #     else:
        #         t_freq[b] += 1
        # for c in t:
        #     if c not in s or t_freq[c] != s_freq[c]:
        #         return c
        # return
        # 法二：采用异或的方式
        res = 0
        for char in s+t:
            res ^= ord(char)
        return chr(res)
if __name__ == '__main__':
    s = "abcd"
    t = "abcde"
    print(Solution().findTheDifference(s, t))

        